<?php
/*
# ------------------------------------------------------------------------
# JA Job Board Package
# ------------------------------------------------------------------------
# Copyright (C) 2004-2010 JoomlArt.com. All Rights Reserved.
# @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
# Author: JoomlArt.com
# Websites: http://www.joomlart.com - http://www.joomlancers.com.
# ------------------------------------------------------------------------
*/
jimport ( 'joomla.application.component.view' );

class JAJobBoardViewJACustomtmpl extends JAView {
	/**
	 * Display the view
	 */
	function display($tmpl = null) {		
		$task = JRequest::getVar ( "task", '' );
		switch ($task) {
			case 'add' :
			case 'edit' :
				JAJobBoardViewJACustomtmpl::displayForm ();
				break;
			default :
				JAJobBoardViewJACustomtmpl::displayListItems ();
		}
		parent::display ( $tmpl );
	}
	
	/**
	 * Display List of items
	 */
	function displayListItems() {
		global $mainframe, $option;
		$option_1 = $option . '.jacustomtmpl';
		$search = $mainframe->getUserStateFromRequest ( "$option_1.search", 'search', '', 'string' );
		$lists ['search'] = JString::strtolower ( $search );
		$lists ['search'] = $mainframe->getUserStateFromRequest ( "$option_1.search", 'search', '', 'string' );
		$filter_folder = $mainframe->getUserStateFromRequest ( "$option_1.folder", 'folder', '', 'string' );
		$lists ['option'] = $option;
		
		$files = $folders = $put = array ();
		
		$path = JPATH_COMPONENT_SITE . DS . 'views';
		$folders = JFolder::folders ( $path );
		
		if ($folders) {
			$put [] = JHTML::_ ( 'select.option', '', 'Please Select Folder' . '...' );
			foreach ( $folders as $k => $folder ) {
				$files [$k] = JFolder::files ( $path . DS . $folder . DS . 'tmpl' );
				$put [] = JHTML::_ ( 'select.option', $folder, $folder );
			}
			$lists ['folders'] = JHTML::_ ( 'select.genericlist', $put, 'folder', '', 'value', 'text', $filter_folder );
		}
		
		$template = getTemplate();
		
		$this->assignRef ( 'template', $template );
		$this->assignRef ( 'lists', $lists );
		$this->assignRef ( 'folders', $folders );
		$this->assignRef ( 'files', $files );
		$this->assignRef ( 'path', $path );
	
	}
	/**
	 * Display edit form
	 */
	function displayForm() {
		global $option, $mainframe;
		
		$folder = JRequest::getVar ( 'folder', '' );
		$file = JRequest::getVar ( 'file', '' );
		$prev_path = $folder . DS . 'tmpl' . DS . $file;
		
		$path = JPATH_COMPONENT_SITE . DS . 'views' . DS;
		
		$template = getTemplate();
		$override_content = '';
		$is_override = false;
		if(JFile::exists(JPATH_SITE . DS. 'templates'. DS . $template. DS. 'html'. DS. 'com_jajobboard' . DS. $folder .DS .$file )){
			$override_content = JFile::read(JPATH_SITE . DS. 'templates'. DS . $template. DS. 'html'. DS. 'com_jajobboard' . DS. $folder .DS .$file);
			$is_override = true;
		}
		
		$content = JFile::read ( $path . $prev_path );
		
		$this->assignRef ( 'template', $template );
		$this->assignRef ( 'content', $content );
		$this->assignRef ( 'override_content', $override_content );
		$this->assignRef ( 'is_override', $is_override );
		$this->assignRef ( 'file', $file );
		$this->assignRef ( 'folder', $folder );
		$this->assignRef ( 'option', $option );
		$this->assign ( 'path_override', JPATH_SITE . DS. 'templates'. DS . $template. DS. 'html'. DS. 'com_jajobboard' . DS. $folder .DS .$file);
	}
		
	function menu() {
		
		$view = JRequest::getVar ( 'view', 'jacustomtmpl' );
		
		?>
<div class="t">
<div class="t">
<div class="t"></div>
</div>
</div>
<div class="m">
<ul id="submenu">
	<li><a
		href="index.php?option=com_jajobboard&view=jacustomtmpl&menuId=<?php
		echo JRequest::getVar ( 'menuId' );
		?>"
		class="<?php
		if ($view == null || $view == 'jacustomtmpl')
			echo 'active'?>">
							<?php
		echo JText::_ ( 'Layout template' );
		?>
						</a></li>
	<li><a
		href="index.php?option=com_jajobboard&view=jacustomcss&menuId=<?php
		echo JRequest::getVar ( 'menuId' );
		?>"
		class="<?php
		if ($view == 'jacustomcss')
			echo 'active'?>">
							<?php
		echo JText::_ ( 'CSS' );
		?>
						</a></li>
</ul>
<div class="clr"></div>
</div>
<div class="b">
<div class="b">
<div class="b"></div>
</div>
</div>
<?php
	}
}
?>